package com.tech.algorithm;

import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
 * @Description:
 * @Author: zl
 * @Date: 2019/9/3 17:59
 */
public class Java8 {

    public static void main(String[] args) {


        String REGEX = "中人";//
        String INPUT = "中国人";
        Pattern p = Pattern.compile(REGEX);
        Matcher m = p.matcher(INPUT);

//        Matcher m1 = ;

        System.out.println("lookingAt():" + m.lookingAt());
        System.out.println("matches():" + m.matches());
        System.out.println("matches():" + m.find(0));


        List<String> lines = Arrays.asList("测试点点", "徕客自测", "徕客营销");

        List<String> result = lines.stream()                // convert list to stream
                .filter(line -> Pattern.compile("徕自").matcher(line).find(0))     // we dont like ricky
                .collect(Collectors.toList());              // collect the output and convert streams to a List

        result.forEach(System.out::println);
    }
}
